<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "insurance_project".
 *
 * @property integer $project_id
 * @property string $project_code
 * @property integer $project_order
 * @property string $provider_id
 * @property string $project_name
 * @property string $project_desc
 * @property string $record_number
 * @property string $ctime
 * @property string $status
 */
class InsuranceProject extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'insurance_project';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['project_order'], 'integer'],
            [['ctime','min_amount'], 'safe'],
            [['project_code', 'record_number'], 'string', 'max' => 32],
            [['provider_id', 'status'], 'string', 'max' => 16],
            [['project_name'], 'string', 'max' => 128],
            [['project_desc'], 'string', 'max' => 256],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'project_id' => 'Project ID',
            'project_code' => 'Project Code',
            'project_order' => 'Project Order',
            'provider_id' => 'Provider ID',
            'project_name' => 'Project Name',
            'project_desc' => 'Project Desc',
            'record_number' => 'Record Number',
            'ctime' => 'Ctime',
            'status' => 'Status',
        ];
    }

    public static function checkProductIsExist($code){
        return static::find()->where(["project_code"=>$code])->limit(1)->one();
    }
}
